<%@page import="java.util.List"%>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>Editer</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
	<link rel="stylesheet" type="text/css" href="./html/css/style.css"></link>
	<script charset="utf-8" type="text/javascript" src="./html/js/jquery.js"></script>
	<script charset="utf-8" type="text/javascript" src="./html/js/table.js"></script>
 <style type="text/css">
.textarea {
	background-color: #141414;
	color: #F8F8F8;
	font: 14px/normal 'Monaco', 'Menlo', 'Ubuntu Mono', 'Consolas',
		'source-code-pro', monospace;
}

.editor {
	margin: 0;
	position: absolute;
	top: 0;
	bottom: 0;
	left: 150;
	right: 0;
}

.ace_gutter {
	background: #232323;
	color: #E2E2E2;
}

.ace_gutter {
	position: absolute;
	overflow: hidden;
	width: auto;
	top: 0;
	bottom: 0;
	left: 0;
	cursor: default;
	z-index: 4;
	-ms-user-select: none;
	-moz-user-select: none;
	-webkit-user-select: none;
	user-select: none;
	width: 150px;
	height:550px;
}
.Xax{
   color: #AC885B;
   text-decoration:none;
}
</style>
  </head>
  
  <body>
    <div class="ace_gutter">
    <table class="bordered">
		<thead>
			<tr>
			   <th><input type="checkbox"  id="checkAll" name="checkAll"/></th>
				<th>FileName</th>
			</tr>
		</thead>
       <%
       String fileStr = request.getAttribute("fileStr") + "";
       String checked = request.getAttribute("checked") + "";
       if(fileStr != null)
       {
          String [] filename = fileStr.split(",");
          for(String file : filename)
          {
              String id = file.substring(0,file.lastIndexOf("."));
              %>
              <tr onclick="">
              <% 
                 String flag = "";
                 if (checked != "" && checked.equals(file))
                 {
                     flag = "checked='checked'";
                 }
              
              %>
               <td><input type="checkbox" id="<%=id%>" name="fileName" value="<%=file%>" <%=flag%> /></td>
              <td><a href="javascript:showData('<%=path%>/editerFreeMarkerServlet?editer=show&fileName=<%=file%>','<%=id%>','<%=file%>')" class="Xax" name="fileName" ><%=file%></a></td>
              </tr>
              <% 
          }
       }
        %>
      </table>
    </div>
	<div class="editor">
		<form name="example" method="post" action="editerFreeMarkerServlet">
		<input type="hidden" name="editer" value="true" />
		<input type="hidden" name="fileName" id="fileABC" value="<%=checked%>" />
		<%
		     String str = request.getAttribute("list").toString();
		 %>
		<textarea class="textarea" name="content1" id="content1" cols="100" rows="8"style="width:100%;height:550px;"><%=htmlspecialchars(str)%></textarea>
		<input type="submit" name="button" value="更新内容"/> (提交快捷键: Ctrl + Enter)
	</form>
	</div>
</body>
</html>
<%!
private String htmlspecialchars(String str) {
	str = str.replaceAll("&amp;", "&");
    str = str.replaceAll("&lt;", "<");
    str = str.replaceAll("&gt;",">");
    str = str.replaceAll( "&quot;","\"");
    str = str.replaceAll( "&nbsp;","");
	return str;
}
%>
